package com.tsing.basic.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tsing.basic.service.ILogService;
import com.tsing.basic.vo.req.IdsReqVo;
import com.tsing.basic.vo.req.LogPageReqVo;
import com.tsing.basic.vo.resp.LogRespVo;
import com.tsing.common.annotations.SystemLog;
import com.tsing.common.utils.ResultUtil;
import com.tsing.common.vo.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author TheTsing
 * @version 1.0
 * @date 2021/4/22 11:50
 */
@Api(tags = "日志管理")
@RestController
@RequestMapping("/log")
public class LogController {

    @Autowired
    private ILogService logService;

    @DeleteMapping("/deleteLog")
    @ApiOperation(value = "删除日志")
    @SystemLog(description = "删除日志")
    public ResultData deleteLog(@Validated @RequestBody IdsReqVo reqVo) {
        logService.deleteLog(reqVo);
        return ResultUtil.success();
    }

    @GetMapping("/logPage")
    @ApiOperation(value = "日志分页")
    @SystemLog(description = "日志分页")
    public ResultData<Page<LogRespVo>> logPage(@Validated LogPageReqVo reqVo) {
        return ResultUtil.success(logService.logPage(reqVo));
    }

}
